if (wpt->description != wpt->shortname) {
if (wpt->HasUrlLink()) {
*file_out << "<a href=\"" << wpt->GetUrlLink().url_ << "\">"
- << html_entitize(wpt->description) << "</a>";
+ << wpt->description.toHtmlEscaped() << "</a>";
} else {
- *file_out << html_entitize(wpt->description);
+ *file_out << wpt->description.toHtmlEscaped();
}
if (!wpt->gc_data->placer.isEmpty()) {
*file_out << " by " << wpt->gc_data->placer;
logpart = xml_findfirst(curlog, "groundspeak:finder");
if (logpart) {
*file_out << "<span class=\"gpsbabellogfinder\">"
- << html_entitize(logpart->cdata) << "</span> on ";
+ << logpart->cdata.toHtmlEscaped() << "</span> on ";
}
logpart = xml_findfirst(curlog, "groundspeak:date");
s = logpart->cdata;
}
- *file_out << html_entitize(s);
+ *file_out << s.toHtmlEscaped();
}
*file_out << "</p>\n";
HtmlFormat::html_index(const Waypoint* wpt) const
{
*file_out << " <a href=\"#" << create_id(waypoint_number) << "\">"
- << html_entitize(wpt->shortname) << " - " << html_entitize(wpt->description)
+ << wpt->shortname.toHtmlEscaped() << " - " << wpt->description.toHtmlEscaped()
<< "</a><br>\n";
}
#endif
}
-struct entity_types {
- const char* text;
- const char* entity;
- int not_html;
-};
-
-static
-entity_types stdentities[] = {
- { "&", "&", 0 },
- { "'", "'", 1 },
- { "<", "<", 0 },
- { ">", ">", 0 },
- { "\"", """, 0 },
- { "\x01", " ", 1 }, // illegal xml 1.0 character
- { "\x02", " ", 1 }, // illegal xml 1.0 character
- { "\x03", " ", 1 }, // illegal xml 1.0 character
- { "\x04", " ", 1 }, // illegal xml 1.0 character
- { "\x05", " ", 1 }, // illegal xml 1.0 character
- { "\x06", " ", 1 }, // illegal xml 1.0 character
- { "\x07", " ", 1 }, // illegal xml 1.0 character
- { "\x08", " ", 1 }, // illegal xml 1.0 character
- // { "\x09", " ", 1 }, legal xml 1.0 character
- // { "\x0a", " ", 1 }, legal xml 1.0 character
- { "\x0b", " ", 1 }, // illegal xml 1.0 character
- { "\x0c", " ", 1 }, // illegal xml 1.0 character
- // { "\x0d", " ", 1 }, legal xml 1.0 character
- { "\x0e", " ", 1 }, // illegal xml 1.0 character
- { "\x0f", " ", 1 }, // illegal xml 1.0 character
- { "\x10", " ", 1 }, // illegal xml 1.0 character
- { "\x11", " ", 1 }, // illegal xml 1.0 character
- { "\x12", " ", 1 }, // illegal xml 1.0 character
- { "\x13", " ", 1 }, // illegal xml 1.0 character
- { "\x14", " ", 1 }, // illegal xml 1.0 character
- { "\x15", " ", 1 }, // illegal xml 1.0 character
- { "\x16", " ", 1 }, // illegal xml 1.0 character
- { "\x17", " ", 1 }, // illegal xml 1.0 character
- { "\x18", " ", 1 }, // illegal xml 1.0 character
- { "\x19", " ", 1 }, // illegal xml 1.0 character
- { "\x1a", " ", 1 }, // illegal xml 1.0 character
- { "\x1b", " ", 1 }, // illegal xml 1.0 character
- { "\x1c", " ", 1 }, // illegal xml 1.0 character
- { "\x1d", " ", 1 }, //illegal xml 1.0 character
- { "\x1e", " ", 1 }, //illegal xml 1.0 character
- { "\x1f", " ", 1 }, //illegal xml 1.0 character
- { nullptr, nullptr, 0 }
-};
-
-static
-QString
-entitize(const char* str, bool is_html)
-{
- char* p;
- char* tmp;
- char* xstr;
-
- entity_types* ep = stdentities;
- int elen = 0;
- int ecount = 0;
-
- /* figure # of entity replacements and additional size. */
- while (ep->text) {
- const char* cp = str;
- while ((cp = strstr(cp, ep->text)) != nullptr) {
- elen += strlen(ep->entity) - strlen(ep->text);
- ecount++;
- cp += strlen(ep->text);
- }
- ep++;
- }
-
- /* enough space for the whole string plus entity replacements, if any */
- tmp = (char*) xcalloc((strlen(str) + elen + 1), 1);
- strcpy(tmp, str);
-
- if (ecount != 0) {
- for (ep = stdentities; ep->text; ep++) {
- p = tmp;
- if (is_html && ep->not_html) {
- continue;
- }
- while ((p = strstr(p, ep->text)) != nullptr) {
- elen = strlen(ep->entity);
-
- xstr = xstrdup(p + strlen(ep->text));
-
- strcpy(p, ep->entity);
- strcpy(p + elen, xstr);
-
- xfree(xstr);
-
- p += elen;
- }
- }
- }
-
- QString rv(tmp);
- xfree(tmp);
- return rv;
-}
-
-/*
- * Public callers for the above to hide the absence of &apos from HTML
- */
-
-[[deprecated("Use xmlstreamwriter.")]] QString xml_entitize(const QString& str)
-{
- return entitize(CSTR(str), false);
-}
-
-QString html_entitize(const QString& str)
-{
- return entitize(CSTR(str), true);
-}
-
/*
* xml_tag utilities
*/